﻿@model CapokunMvcTest.Models.Song
@{
    Layout = "~/Views/Shared/_Layout.cshtml";
    if (Model != null)
    {
        ViewBag.Title = Model.SongId;

        ViewBag.ogTitle = Model.SongId;
        ViewBag.ogType = "capokun:Capoeira_song";
        //ViewBag.ogUrl = "http://beta.capokun.com/songs/" + Model.SongId.Replace(" ","%20");
        ViewBag.ogUrl = "http://beta.capokun.com/songs/" + HttpUtility.UrlPathEncode(Model.SongId);
        ViewBag.ogDescription = Capokun.Tools.HtmlRemoval.StripTagsRegex(Model.Content);

        //var m = $("meta[name=locale]");    
        //alert(m.attr("content"));

    }
    else
    {
        ViewBag.Title = "Chanson introuvable";
    }
}
<script type="text/javascript">


    function postCook() {
        FB.api('/me/permissions', function (response) {
            $.logThis(response);
        });

        var ogUrl = $('meta[property="og:url"]').attr("content");
        FB.api(
        //        '/me/capokun:learn?capoeira_song=' + ogUrl + '&access_token=' + accessToken,
        '/me/capokun:learn?capoeira_song=' + ogUrl,
        'post',
        function (response) {
            if (!response || response.error) {
                if (response != null && response.error != null) {
                    alert('Error. Responce error message: ' + response.error.message);
                }
                else {
                    alert('Error occured');
                }
            } else {
                alert('Cook was successful! Action ID: ' + response.id);
            }
        });
    }
</script>
<section id="contentSongList" class="body">
    <div id="tabs-1">
        <fb:login-button show-faces="true" width="200" max-rows="1" scope="publish_actions">
            </fb:login-button>
        @*<fb:add-to-timeline></fb:add-to-timeline>*@
        <form>
        <input type="button" value="Cook" onclick="postCook()" />
        </form>
        <div id="ModelContent">
        </div>
        @if (Model != null)
        {
            <script>
                var ModelJson = {
                    "SongId": "@Model.SongId",
                    "SubmittedBy": "@Model.SubmittedBy"
                };
                var htmlContent = createMVCContent(ModelJson);
                $("#ModelContent").html(htmlContent);
            </script>
                
            <h2>
                @Model.SongId
                @if (!string.IsNullOrEmpty(Model.SongId_en))
                {
                    <span style="font-size: 0.7em">(@Model.SongId_en)</span>
                }
            </h2>
            @Html.Raw(Model.Link)
            <br />
            <div class="editor-labelTwoCols">
                <div class="editor-label">
                    <h3>
                        Portuguese</h3>
                </div>
                <div class="editor-label">
                    <h3>
                        English</h3>
                </div>
            </div>
            <div class="contentTwoCols">
                <div>@Html.Raw(Model.Content)</div>
                <div>
                    @if (string.IsNullOrEmpty(Model.Content_en))
                    {
                        <p>
                            <i>Translation not done.<br />
                                @Html.ActionLink("Add a translation", "Edit/" + Model.SongId, "Song")
                            </i>
                        </p>
                    }
                    else
                    {
                        @Html.Raw(Model.Content_en);
                    }
                </div>
            </div>
            <br />
            <div data-href="http://www.capokun.com/en-US/songs/@Model.SongId"
                 class="fb-like" data-send="false" data-width="450" data-show-faces="true">
            </div>
        }
        else
        {
            <p>
                Unknown song</p>
        }
    </div>
</section>
